package com.atstudy.dao;

import com.atstudy.entites.Spu;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/2/9 10:34
 * @copyright: 博为峰
 */
public interface SpuDao {
    //------------------------参数----------------------------------------------------
    @Select("select * from spu where spu_id = #{spuId} and spu_name = #{spuName}")
    @Results(id = "spuMap", value = {
            @Result(property = "spuId", column = "spu_id"),
            @Result(property = "spuName", column = "spu_name"),
            @Result(property = "spuTitle", column = "spu_title"),
    })
    public List<Spu> getSpu(Spu spu);

    @Select("select * from spu where spu_name like ${spuName}")
    @ResultMap("spuMap")
    public List<Spu> getSpuMap(HashMap<String, String> map);

    @Select("select * from spu where spu_name = #{name} and spu_id = #{id}")
//    @Select("select * from spu where spu_name = #{param2} and spu_id = #{param1}")
    @ResultMap("spuMap")
    public List<Spu> getSpuByParam(@Param("id") Long id, @Param("name") String name);

    //------------------------一级缓存----------------------------------------------------
    @Select("select * from spu where spu_id = #{id}")
    @ResultMap("spuMap")
    public List<Spu> getSpuById(@Param("id") Long id);

    //------------------------二级缓存----------------------------------------------------
    public List<Spu> getSpuByIdSec(@Param("id") Long id);

    //------------------------动态SQL----------------------------------------------------
    public List<Spu> getSpuSQL(Spu spu);

    public int updateSpuSQL(Spu spu);

    public List<Spu> getSpuByIdSQL(List<Long> list);
}
